package com.wtcrazy.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wtcrazy.entity.Product;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ProductMapper extends BaseMapper<Product> {
    @Select("select * from product")
    List<Product> findAll();

    @Delete("delete from  product where id = #{id}")
    Integer deleteById(@Param("id") Integer id);

    @Select("select * from product where name like concat('%', #{name} ,'%') limit #{pageNum},#{pageSize}")
    List<Product> selectPage(Integer pageNum, Integer pageSize, String name);

    @Select("select count(*) from product where name like concat('%', #{name} ,'%')")
    Integer selectTotal(String name);

    void deleteProduct(@Param("id") String id);

}
